1. Field of the Invention
The present invention relates to an electronic control unit and method, which executes on-board rewrite of control programs and control data used for regulating operations of predetermined mechanisms or objects to be controlled.
2. Description of Related Art
In an electronic control unit which is in practical use for controlling such objects as an engine and transmission of an automobile, there is provided a nonvolatile read-only memory (electrically rewritable ROM) that is electrically erasable and rewritable. The rewritable ROM is so designed that control programs and control data stored therein can be rewritten after the production of the electronic control unit.
In normal operation, this kind of electronic control unit controls an engine and other control objects according to control programs and control data stored in the electrically rewritable ROM thereof. When an external memory rewrite device is connected to the electronic control unit and a rewrite command is issued, the electronic control unit recognizes that a rewrite condition is met. Then, the electronic control unit performs transition to a rewrite mode, and in the rewrite mode, the contents of the electrically rewritable ROM are replaced with new contents (program and/or data) received from the memory rewrite device.
In the electronic control unit having the above on-board rewritable memory, it is rather easy to cope with a possible requirement that an operation sequence (control sequence) is to be altered due to any cause after placement on the market.
However, in the flash memory or EEPROM employed as an electrically rewritable ROM in the electronic control unit, a limitation is imposed on the allowable maximum number of times the contents stored therein may be rewritten (i.e., allowable maximum erase/rewrite count of the contents of the memory).
Therefore, in the above electronic control unit, a rewrite count of the contents stored in the electrically rewritable ROM (rewrite count of the electrically rewritable ROM or rewrite count) is retained in a count information storage region allocated in the electrically rewritable ROM so that the contents of the electrically rewritable ROM will not be rewritten repeatedly beyond an allowable maximum rewrite count guaranteed for the electrically rewritable ROM.
For this reason, it is proposed to count the number of rewrite of the rewritable ROM every time the storage contents in each storage block is erased and rewritten. This counting method necessarily increases above the actual number of rewrite of the rewritable ROM, because each rewrite of one block is counted. That is, if three blocks are rewritten at one time, the count of rewrite is increased by three.
If the number of rewrite of the rewritable memory is counted block by block, the capacity or storage locations for storing the counted number is increased.